#!/bin/bash
clear
rm a.out

ROOTDIR="/home/dev/TI/StellarisWare"
LM4FLASH="lm4flash"
#ROOTDIR="/home/atreyu/Source/stellaris"
#LM4FLASH="~/Source/lm4tools/lm4flash/lm4flash"



echo "Compiling..."
arm-none-eabi-gcc lab4.c startup_gcc.c linkedqueue.c uart.c syscalls.c -g -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -Os -ffunction-sections -fdata-sections -MD -std=c99 -DPART_LM4F120H5QR -c -I$ROOTDIR -DTARGET_IS_BLIZZARD_RA1 -L{$ROOTDIR}/stellarisware/driverlib/gcc-cm4f/ -ldriver-cm4f

echo "Linking..."
arm-none-eabi-ld -T linker.ld --entry ResetISR -o a.out startup_gcc.o lab4.o linkedqueue.o uart.o syscalls.o --gc-sections

echo "Copying object files..."
arm-none-eabi-objcopy -O binary a.out lab4.bin

echo "Flashing to rom..."
#lm4flash timerled.bin
sudo $LM4FLASH lab4.bin

echo "Build terminated."

#ta info: yuanye@uvic.ca

#sudo minicom -D /dev/rfcomm0 configuration stellarisbt
